<template>
  <el-container>
    <el-header >
      <i class="fa fa-bug fa-3x"></i>
      <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect" >
        <el-menu-item align="center">
          <el-form :inline="true">
            <el-form-item>
              <el-input placeholder="搜索它不香吗"></el-input>
            </el-form-item>
            <el-form-item><el-button>搜索</el-button></el-form-item>
          </el-form>
        </el-menu-item>
        <el-menu-item route="true" :index="item.path" v-for="(item,i) in menuData" :key="i">{{item.name}}</el-menu-item>
      </el-menu>
    </el-header>

    <el-main>
      <div class="router-p">
        <el-backtop target=".router-p"></el-backtop>
        <router-view/>
      </div>
    </el-main>

    <el-footer>Footer</el-footer>

  </el-container>
</template>

<script>
  export default {
    name: 'Home',
    data(){
      return {
        activeIndex: '/Book',
        menuData:[
          {"name":"首页","path":"/Index"},
          {"name":"文章","path":"/Book"},
          {"name":"记忆","path":"/TimeLine"},
          {"name":"创作","path":"/Login"}
        ]
      }
    },
    components: {
    },
    created () {
    },
    mounted(){
      this.init()
    },
    methods: {
      init(){
        var height = document.documentElement.clientHeight
        var main = document.getElementsByClassName("el-main")[0]
        console.log(height)
        // main.style.height = (height - 120) +"px"
      },
      handleSelect(key) {
        this.$router.push({path:key})
      }
    }
  }

</script>

<style scoped>

  .el-header, .el-footer {
    width: 100%;
    color: #333;
    text-align: center;
    line-height: 50px;
    max-height: 50px;
    padding: 0px;
  }
  .el-header{
    position:fixed;
    z-index: 999999999;
    background: #fff;
  }
  .fa-bug{
    float: left;
    margin-left: 10px;
    margin-top: 5px;
  }
  .el-menu{
    float: right;
    margin: 0 auto;
  }
  .el-menu-item, .el-submenu__title{
    height: 50px;
    line-height: 50px;
  }
  .el-main {
    background-color: #f6f6f6;
    color: #333;
    text-align: center;
    padding-top: 20px;
    margin-top: 40px;
    padding-bottom: 10px;
  }
  .router-p{
    max-width: 900px;
    margin: 0 auto;
  }

</style>
